package com.kefu.robot.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "同义词")
public class RobotSynonymSearchVo extends AbstractSearchVo {


    @ApiModelProperty(name = "title", value = "标准词")
    private String title;


    public <T>QueryWrapper<T> builder() {
   		QueryWrapper<T> wrapper=Wrappers.query();

        //标准词
        if (StringUtils.isNotBlank(title)) {
            wrapper.and(wr->{
                wr.like("title", title)
                        .or().like("question", title);
            });
        }

        wrapper.eq("tenant_id", KefuContext.getKefuContext().getTenantId());

        return wrapper;

    }

}